// pages/wodeqian_m/wodeqian_m.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var qian_id= options.qian_id;
    app.globalData.img_id2 = ''
    if(app.globalData.fq_sjid2==1){
      var fq_sid = options.fq_sid;
      app.globalData.fq_sid = fq_sid
      console.log(app.globalData.fq_sid)
    }
    app.globalData.qian_id = qian_id
    wx.request({
      url: app.globalData.url_l+'api/member/qianming_list',
      method: 'post',
      data: {
        uid: app.globalData.uid
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        that.setData({
          qian_ming:res.data
        })
      }
    })
  },
  xz:function(e){
    console.log(1)
    var that = this;
    that.data.page++;
    var mr_id = e.currentTarget.dataset.id; 
    var mr_url = e.currentTarget.dataset.url; 
   if(that.data.page==2){
    if(app.globalData.qian_id==1){
      wx.showToast({
        title: '选择成功',
        icon: 'none',
        duration: 1000,
        success:function(){
          console.log('haha');
          setTimeout(function () {
            wx.navigateBack()
            that.data.page=1
          }, 1000) //延迟时间
        }
      })
      app.globalData.mr_url = mr_url
  }else if(app.globalData.fq_sid==99){
    
    wx.showToast({
      title: '选择成功',
      icon: 'none',
      duration: 1000,
      success:function(){
        console.log('haha');
        setTimeout(function () {
          wx.navigateBack()
          that.data.page=1
        }, 1000) //延迟时间
      }
    })
    app.globalData.fq_sjid1=1,
    app.globalData.img_id2 = 1
    app.globalData.mr_url = mr_url
  }else{
    that.data.page=1
  }
   }else{
    that.data.page=1
   }
  
  },
  previewImage(e) {
    var that = this;
    var cur = e.target.dataset.src; //获取本地一张图片链接
    console.log(cur)
    wx.previewImage({
      current: cur, //字符串，默认显示urls的第一张
      urls: [cur] // 数组，需要预览的图片链接列表
    })

  },
  shan_c:function(e){
    var that = this;
    var shan_c = e.currentTarget.dataset.id; 
    wx.showModal({
      title: '温馨提示',
      content: '是否删除该签名',
      success (res) {
        if (res.confirm) {
          wx.request({
            url: app.globalData.url_l+'api/member/qianming_de',
            method: 'post',
            data: {
              id: shan_c,
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
              console.log(res)
              if(res.data.code==1){
                wx.showToast({
                  title: '删除成功！',
                  icon: 'none',
                  duration: 1000,
                  success:function(){
                    setTimeout(function () {
                      //要延时执行的代码
                      wx.request({
                        url: app.globalData.url_l+'api/member/qianming_list',
                        method: 'post',
                        data: {
                          uid: app.globalData.uid
                        },
                        header: {
                          'content-type': 'application/x-www-form-urlencoded'
                        },
                        success: function (res) {
                          console.log(res)
                          that.setData({
                            qian_ming:res.data
                          })
                        }
                      })
                    }, 500) //延迟时间
                  }
                })
               
              }else{
                wx.showToast({
                  title: '删除失败！',
                  icon: 'none',
                  duration: 500
                })
              }
            }
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
   
  },
  tianjia_qm:function(e){
    wx.navigateTo({
      url: '../qianming/qianming',
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    wx.request({
      url: app.globalData.url_l+'api/member/qianming_list',
      method: 'post',
      data: {
        uid: app.globalData.uid
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        that.setData({
          qian_ming:res.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})